<template>
  <div>
    <el-row :gutter="15">
      <el-form ref="userCreateForm" :model="userCreateFormData" :rules="rules" size="mini"
        label-width="100px">
        <el-col :span="12">
          <el-form-item label="管理员名" prop="username">
            <el-input v-model="userCreateFormData.username" placeholder="请输入管理员" :maxlength="10"
              show-word-limit clearable prefix-icon='el-icon-user-solid' :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="密码" prop="password">
            <el-input v-model="userCreateFormData.password" placeholder="请输入密码" clearable
              prefix-icon='el-icon-info' :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item size="large">
            <el-button type="primary" @click="submitForm">提交</el-button>
            <el-button @click="resetForm">重置</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>
  </div>
</template>
<script>
import {userAdd} from '@/api/user'
export default {
  components: {},
  props: [],
  data() {
    return {
      userCreateFormData: {
        username: undefined,
        password: undefined,
      },
      rules: {
        username: [{
          required: true,
          message: '请输入用户名',
          trigger: 'blur'
        }],
        password: [{
          required: true,
          message: '请输入密码',
          trigger: 'blur'
        }],
      },
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    submitForm() {
      this.$refs['userCreateForm'].validate(valid => {
        if (!valid) return
        userAdd(this.userCreateFormData)
      })
    },
    resetForm() {
      this.$refs['userCreateForm'].resetFields()
    },
  }
}

</script>
<style>
</style>
